package com.daka.controller;

import com.daka.entity.VolunteerWelfare;
import com.daka.enumerate.StatusCode;
import com.daka.service.*;
import com.daka.tools.ConfigUtil;
import com.daka.vo.response.BaseResponseVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by yangx
 * Date: 2016/8/1 0001
 * Time: 11:05
 */

@Controller
@RequestMapping("/volunteer")
@Slf4j
public class VolunteerController {

    @Resource
    private UserService userService;

    @Resource
    private VolunteerService volunteerService;

    @Resource
    private VolunteerInsuranceService volunteerInsuranceService;

    @Resource
    private VolunteerMoneyService volunteerMoneyService;

    @Resource
    private VolunteerWelfareService volunteerWelfareService;

    @RequestMapping(method = RequestMethod.POST, value = "/test")
    @ResponseBody
    public BaseResponseVo test() {
        ConfigUtil.buildConfig();

        log.info(" ===================================================       user start!");
        userService.migrate(ConfigUtil.selectMax, ConfigUtil.selectMin);
        log.info(" ===================================================       user end!");

        log.info(" ===================================================       user correction start!");
        userService.correction();
        log.info(" ===================================================       user correction end!");

        log.info(" ===================================================       volunteer start!");
        volunteerService.migrate(ConfigUtil.selectMax, ConfigUtil.selectMin);
        log.info(" ===================================================       volunteer end!");

        log.info(" ===================================================       volunteer correction start!");
        volunteerService.correction();
        log.info(" ===================================================       volunteer correction end!");

        return new BaseResponseVo(StatusCode.OK.getCode(), StatusCode.OK.getMessage());
    }

    @RequestMapping(method = RequestMethod.POST, value = "/testV")
    @ResponseBody
    public BaseResponseVo testV() {
        ConfigUtil.buildConfig();

        volunteerService.migrate(ConfigUtil.selectMax, ConfigUtil.selectMin);

        return new BaseResponseVo(StatusCode.OK.getCode(), StatusCode.OK.getMessage());
    }

    @RequestMapping(method = RequestMethod.POST, value = "/testI")
    @ResponseBody
    public BaseResponseVo testI() {
        ConfigUtil.buildConfig();

        volunteerInsuranceService.migrate(ConfigUtil.selectMax, ConfigUtil.selectMin);

        return new BaseResponseVo(StatusCode.OK.getCode(), StatusCode.OK.getMessage());
    }

    @RequestMapping(method = RequestMethod.POST, value = "/testM")
    @ResponseBody
    public BaseResponseVo testM() {
        ConfigUtil.buildConfig();

        volunteerMoneyService.migrate(ConfigUtil.selectMax, ConfigUtil.selectMin);

        return new BaseResponseVo(StatusCode.OK.getCode(), StatusCode.OK.getMessage());
    }

    @RequestMapping(method = RequestMethod.POST, value = "/testW")
    @ResponseBody
    public BaseResponseVo testW() {
        ConfigUtil.buildConfig();

        volunteerWelfareService.migrate(ConfigUtil.selectMax, ConfigUtil.selectMin);

        return new BaseResponseVo(StatusCode.OK.getCode(), StatusCode.OK.getMessage());
    }
}







